import random

user_input_number = ("1","2","3","4","5")

a=[]
for x in "ABCDEFGHIJKLMNO":
    a.append((x, random.randint(35,100)))
    dct = dict(a)

lst = sorted( dct.items(), key = lambda x: x[1], reverse=True)
dct1 = dict(lst)
avg = sum(dct.values()) / len(dct)
max = max(dct.values())
min = min(dct.values())

def menu():
    print("欢迎使用该学生成绩管理系统！".center(55))
    print("1:查询学生成绩")
    print("2:统计学生成绩")
    print("3:查看所有考生成绩")
    print("4:查看不合格人数")
    print("5:结束系统")

def fail():

    score = dct1
    c = list(score.values())
    count = 0
    for i in c:
        if i < 60:
            count = count + 1
    print("不及格人数为{}".format(count))

def total_score():
    print(dct1)

def  stu_find():
    for i in range(10):
        x  = input("请输入你查询学生的名字:")
        if x in dct1.keys():
            print("他的成绩是", dct1[x])
            if dct1[x] > avg:
                print("该生成绩属于上等水平")
                break
            elif dct1[x] == avg:
                print("该生成绩属于中等水平")
                break
            elif dct1[x] < avg:
                print("该生成绩属于下等水平")
                break
        else:
            print("请输入正确的学生名字")

def grade_sta():

    print("学生成绩的平均分是{:^.2f}，最高分是{:.2f},最低分是{:.2f}".format(avg, max, min))

if __name__ == '__main__':
    menu()
    while True:

        stu_input = input("请输入选择的功能：")
        if stu_input in user_input_number:
            if stu_input == "1":
                stu_find()
            elif stu_input == "2":
                grade_sta()
            elif stu_input == "3":
                total_score()
            elif stu_input == "4":
                fail()
            else:
                print("感谢您的使用")
                break
        else:
            print("请输入正确的序号选择！")








